FROM rust:1.82-slim-bookworm

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        build-essential \
        clang \
        libclang-dev \
        make \
        pkg-config \
        cmake \
        ninja-build \
        python3 \
        python3-venv \
        git \
        wget \
        curl \
        ca-certificates \
        xz-utils \
        bzip2 \
        unzip \
        u-boot-tools \
    && rm -rf /var/lib/apt/lists/*

RUN cargo install --locked just

RUN rustup toolchain install nightly-2025-05-20 --profile minimal \
    && rustup component add --toolchain nightly-2025-05-20 \
        rust-src \
        rustfmt \
        clippy \
        llvm-tools-preview \
    && rustup target add --toolchain nightly-2025-05-20 \
        x86_64-unknown-none \
        riscv64gc-unknown-none-elf \
        aarch64-unknown-none \
        aarch64-unknown-none-softfloat \
        loongarch64-unknown-none \
        loongarch64-unknown-none-softfloat

RUN cargo install --locked cargo-binutils

RUN wget -q https://musl.cc/aarch64-linux-musl-cross.tgz \
    && tar -C /opt -xf aarch64-linux-musl-cross.tgz \
    && rm aarch64-linux-musl-cross.tgz

ENV PATH="/opt/aarch64-linux-musl-cross/bin:${PATH}"

WORKDIR /work

CMD ["bash"]
